home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-30 | 3.3 KB | 171 lines | [TEXT/KAHL] |
- /***********************************************************************************
- CExpanderText.cp
-
- Copyright © 1994 B-Ray Software. All rights reserved.
- Developed using Symantec C++ 7.0.2 and Symantec's TCL library.
- Portions of this code courtesy Symantec, Inc.
-
- This code may be freely distributed as long as this notice remains. This code
- may not be used in any commercial software without the consent of B-Ray Software.
-
- ---
-
- ***********************************************************************************/
- #include "ExpanderMessages.h"
-
- #include "CExpanderText.h"
-
- TCL_DEFINE_CLASS_D1( CExpanderText, CExpanderPane );
-
-
- /*
- * CExpanderText constructor
- *
- * Default constructor - should only be called when created by a file read.
- */
-
- CExpanderText :: CExpanderText() : CExpanderPane()
- {
- lineHeight = 0;
- ascent = 0;
-
- TCL_END_CONSTRUCTOR
- }
-
-
- /*
- * CExpanderText constructor
- *
- * Normal constructor - should always be called when created in code.
- */
-
- CExpanderText :: CExpanderText( CView *anEnclosure, CBureaucrat *aSupervisor,
- short aWidth, short aHeight, short aHLoc, short aVLoc,
- SizingOption aHSizing, SizingOption aVSizing )
- : CExpanderPane( anEnclosure, aSupervisor, aWidth, aHeight, aHLoc, aVLoc,
- aHSizing, aVSizing )
- {
- lineHeight = 0;
- ascent = 0;
-
- TCL_END_CONSTRUCTOR
- }
-
-
- /*
- * CExpanderText destructor
- *
- * Just a place-holder for Inspector
- */
-
- CExpanderText :: ~CExpanderText()
- {
- TCL_START_DESTRUCTOR
- }
-
-
- /*
- * TextSizeChanged method
- *
- * Updates expander when size of text has changed.
- */
-
- void CExpanderText :: TextSizeChanged( void )
- {
- short aWidth, aHeight;
-
- aHeight = CalcFrameHeight();
- aWidth = CalcFrameWidth();
- SetExpanderSize( aWidth, aHeight );
- }
-
-
- /*
- * CalcLineHeight method
- *
- * Sets the lineHeight and ascent variables based on the current font settings
- */
-
- void CExpanderText :: CalcLineHeight( void )
- {
- FontInfo fontInfo;
-
- ForceNextPrepare(); // make sure we see any font change
- Prepare(); // setup drawing environment
-
- GetFontInfo( &fontInfo ); // get font info
- lineHeight = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
- ascent = fontInfo.ascent;
- }
-
-
- /*
- * CalcFrameHeight method
- *
- * Returns the height of the frame. This class just returns the size of one line of text.
- */
-
- short CExpanderText :: CalcFrameHeight( void )
- {
- CalcLineHeight();
- return lineHeight;
- }
-
-
- /*
- * CalcFrameWidth method
- *
- * Returns the width of the frame. This class just returns the pane's width.
- */
-
- short CExpanderText :: CalcFrameWidth( void )
- {
- return width;
- }
-
-
- /*
- * ParentMessage method - OVERRIDE
- *
- * Handles kExpanderFontChanged messages. These indicate that the parent has changed
- * the font characteristics of our drawing space. Must update our frame size.
- */
-
- void CExpanderText :: ParentMessage( long message, void *param )
- {
- if ( message == kExpanderFontChanged ) {
- TextSizeChanged();
- }
- else {
- CExpanderPane::ParentMessage( message, param );
- }
- }
-
-
- /*
- * PutTo method - OVERRIDE
- *
- * Writes to the stream all the info we need to save.
- */
-
- void CExpanderText :: PutTo( CStream &stream )
- {
- stream << lineHeight << ascent;
-
- CExpanderPane::PutTo( stream );
- }
-
-
- /*
- * GetFrom method - OVERRIDE
- *
- * Reads from the stream all of the info that we saved.
- */
-
- void CExpanderText :: GetFrom( CStream &stream )
- {
- stream >> lineHeight >> ascent;
-
- CExpanderPane::GetFrom( stream );
- }
-